package com.example.ylsys.plants.model;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.example.ylsys.plants.bean.BackResultBean;
import com.example.ylsys.plants.bean.LoginParamsBean;
import com.example.ylsys.plants.contract.LoginDialogContract;
import com.example.ylsys.plants.database.MyDatabaseHelper;
import com.example.ylsys.plants.net.RetrofitClient;
import com.example.ylsys.plants.net.Url;

import java.util.Map;

import io.reactivex.Observable;

public class LoginDialogModel implements LoginDialogContract.Login_Model
{

    @Override
    public Observable<BackResultBean> ac_Api(Map<String, String> url_map, Map<String, String> post_map) {
        return RetrofitClient.getInstance().getApi(Url.LOGIN_SERVICE_URL).get_role(url_map, post_map);
    }

    @Override
    public Observable<BackResultBean> login_Api(Map<String, String> url_map, Map<String, String> post_map) {
        return RetrofitClient.getInstance().getApi(Url.LOGIN_SERVICE_URL).get_role(url_map, post_map);
    }

    @Override
    public void save_Data(String tel_number, String secret_code, Context context) {
        ContentValues contentValues=new ContentValues();
        contentValues.put("tel_number",tel_number);
        contentValues.put("secret_code",secret_code);
        MyDatabaseHelper helper = new MyDatabaseHelper(context,1);
        SQLiteDatabase mSQLiteDatabase = helper.getWritableDatabase();
        mSQLiteDatabase.insert(MyDatabaseHelper.TABLE_LOGIN,null,contentValues);
        mSQLiteDatabase.close();
    }


}
